

Component({
    properties: {
        value: {
            type: [ Number, String ],
            value: "",
            observer: "formatPrice"
        },
        type: {
            type: String,
            value: ""
        },
        icon: {
            type: String,
            value: "sub"
        },
        color: {
            type: String,
            value: ""
        },
        fontSize: {
            type: [ Number, String ],
            value: ""
        },
        fontWeight: {
            type: String,
            value: ""
        },
        iconSize: {
            type: String,
            value: ""
        },
        iconWeight: {
            type: String,
            value: ""
        }
    },
    attached: function() {
        this.initFont();
    },
    methods: {
        formatPrice: function(e) {
            var i = Math.floor(100 * +e) / 100;
            this.setData({
                value: (0, this.isNumber)(i) ? i : ""
            });
        },
        initFont: function() {
            var t = "del" === this.data.type;
            if (!this.data.fontSize) {
                var e = t ? "28rpx" : "38rpx";
                this.setData({
                    fontSize: e
                });
            }
            if (!this.data.fontWeight) {
                var i = t ? "normal" : "bold";
                this.setData({
                    fontWeight: i
                });
            }
            if (!this.data.color) {
                var a = t ? "#959595" : "#f73451";
                this.setData({
                    color: a
                });
            }
        },
        isNumber : function(e) {
            return null !== e && (("string" != typeof e || "" !== (e = e.trim())) && ("boolean" != typeof e && !isNaN(e)));
        },
    }
});